package com.descartes.mymedia.dao.config;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class EntityManagement {

	private EntityManagerFactory emf;
	private EntityManager entityManager;
	
    private static EntityManagement instance;

	public EntityManagement() {
		emf = Persistence.createEntityManagerFactory("MyMediaApp");
		entityManager = emf.createEntityManager();	
	}

	public static synchronized EntityManagement getInstance() {
		if (instance == null) {
			instance = new EntityManagement();
		}

		return instance;
	}

	public EntityManagerFactory getEmf() {
		return emf;
	}

	public EntityManager getEntityManager() {
		return entityManager;
	}
}
